package com.ims.core.doc.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ims.common.annotation.Log;
import com.ims.common.core.controller.BaseController;
import com.ims.common.core.domain.AjaxResult;
import com.ims.common.enums.BusinessType;
import com.ims.core.doc.domain.TInDeductionStatEntry;
import com.ims.core.doc.service.ITInDeductionStatEntryService;
import com.ims.common.utils.poi.ExcelUtil;
import com.ims.common.core.page.TableDataInfo;

/**
 * 抵扣统计明细Controller
 *
 * @author IMS
 * @date 2024-12-11
 */
@RestController
@RequestMapping("/doc/entry")
public class TInDeductionStatEntryController extends BaseController
{
    @Autowired
    private ITInDeductionStatEntryService tInDeductionStatEntryService;

    /**
     * 查询抵扣统计明细列表
     */
    @PreAuthorize("@ss.hasPermi('doc:entry:list')")
    @GetMapping("/list")
    public TableDataInfo list(TInDeductionStatEntry tInDeductionStatEntry)
    {
        startPage();
        List<TInDeductionStatEntry> list = tInDeductionStatEntryService.selectTInDeductionStatEntryList(tInDeductionStatEntry);
        return getDataTable(list);
    }

    /**
     * 导出抵扣统计明细列表
     */
    @PreAuthorize("@ss.hasPermi('doc:entry:export')")
    @Log(title = "抵扣统计明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TInDeductionStatEntry tInDeductionStatEntry)
    {
        List<TInDeductionStatEntry> list = tInDeductionStatEntryService.selectTInDeductionStatEntryList(tInDeductionStatEntry);
        ExcelUtil<TInDeductionStatEntry> util = new ExcelUtil<TInDeductionStatEntry>(TInDeductionStatEntry.class);
        util.exportExcel(response, list, "抵扣统计明细数据");
    }

    /**
     * 获取抵扣统计明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('doc:entry:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tInDeductionStatEntryService.selectTInDeductionStatEntryById(id));
    }

    /**
     * 新增抵扣统计明细
     */
    @PreAuthorize("@ss.hasPermi('doc:entry:add')")
    @Log(title = "抵扣统计明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TInDeductionStatEntry tInDeductionStatEntry)
    {
        return toAjax(tInDeductionStatEntryService.insertTInDeductionStatEntry(tInDeductionStatEntry));
    }

    /**
     * 修改抵扣统计明细
     */
    @PreAuthorize("@ss.hasPermi('doc:entry:edit')")
    @Log(title = "抵扣统计明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TInDeductionStatEntry tInDeductionStatEntry)
    {
        return toAjax(tInDeductionStatEntryService.updateTInDeductionStatEntry(tInDeductionStatEntry));
    }

    /**
     * 删除抵扣统计明细
     */
    @PreAuthorize("@ss.hasPermi('doc:entry:remove')")
    @Log(title = "抵扣统计明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tInDeductionStatEntryService.deleteTInDeductionStatEntryByIds(ids));
    }
}
